<template >
  <div class="homeSetUp-container">
    <breadcrumb style="position: absolute;width:100%;"></breadcrumb>
    <div class="content">
      <div class="query">
        <div class="btn">
          <el-button type="primary" @click="$router.go(-1)">返回</el-button>
        </div>
      </div>
      <div class="table">
        <el-table :data="couponList" style="width: 100%" height="598">
          <el-table-column prop="cardName" label="会员卡类型" width="100px"></el-table-column>
          <el-table-column prop="overdue" label="会员卡状态"></el-table-column>
          <el-table-column prop="goodsName" label="购买商品" width="400px"></el-table-column>
          <el-table-column prop="orderNo" label="订单编号" width="190px"></el-table-column>
          <el-table-column prop="createTime" label="下单时间"></el-table-column>
          <el-table-column prop="startTime" label="会员生效时间"></el-table-column>
          <el-table-column prop="endTime" label="会员到期时间"></el-table-column>
          <el-table-column prop="amount" label="支付金额（元）"></el-table-column>
          <!-- <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="text" size="small" @click="jump_goods_detail(scope.row.id)">详情</el-button>
            </template>
          </el-table-column>-->
        </el-table>
        <pagination
          :currentPage="currentPage"
          :page="page"
          :total="total"
          :pageSize="pageSize"
          @change-current="currentChange"
          @change-size="sizeChange"
        ></pagination>
      </div>
    </div>
  </div>
</template>
<script>
import breadcrumb from "../../components/breadcrumb";
import pagination from "../../components/page";
import { positions } from "../../api/getData";
export default {
  components: { breadcrumb, pagination },
  data() {
    return {
      currentPage: 1,
      total: 0,
      id: this.$route.query.id,
      couponList: [],
      options1: [
        {
          value: "",
          label: "所有"
        },
        {
          value: "1",
          label: "月卡"
        },
        {
          value: "2",
          label: "季卡"
        },
        {
          value: "3",
          label: "年卡"
        }
      ],
      page: 1,
      pageSize: 10
    };
  },
  props: ["positionsId"],
  created() {
    if (localStorage.getItem("pageMsg")) {
      let pageMsg = JSON.parse(localStorage.getItem("pageMsg"));
      this.currentPage = pageMsg.currentPage;
      this.pageSize = pageMsg.pageSize;
      localStorage.removeItem("pageMsg");
    }
    this.get_goodsList();
  },
  methods: {
    sizeChange(val) {
      this.pageSize = val;
      this.currentPage = 1;
      this.get_goodsList();
    },
    currentChange(val) {
      this.currentPage = val;
      this.get_goodsList();
    },
    // jump_goods_detail(id) {
    //   localStorage.setItem("path", JSON.stringify(this.$route.path));

    //   localStorage.setItem(
    //     "pageMsg",
    //     JSON.stringify({
    //       currentPage: this.currentPage,
    //       pageSize: this.pageSize
    //     })
    //   );
    //   this.$router.push("goodsDetail?id=" + id);
    // },
    get_goodsList(currentPage) {
      let data =
        "userId=" +
        this.id +
        "&size=" +
        this.pageSize +
        "&current=" +
        this.currentPage;
      this.$axios.post("/member/details-list", data).then(result => {
        if (result.data.status == 0) {
          this.couponList = result.data.data.records;
          this.total = result.data.data.total;
          this.page = Math.ceil(result.data.data.total / this.pageSize);
          this.couponList.forEach(item => {
            item.overdue = item.overdue == 1 ? "有效" : "过期";
          });
        }
      });
    }
  }
};
</script>


<style lang="less" >
.homeSetUp-container {
  @import "../../style/table.less";
  @import "../../style/content.less";
  display: flex;
  flex-flow: column;
  position: relative;
  height: 100%;
  .el-table .cell {
    white-space: pre-line !important;
  }
  .content {
    .query {
      .start_time {
        display: flex;
        align-items: center;
      }
      .end_time {
        display: flex;
        align-items: center;
      }
      .btn {
        .el-button {
          width: 70px;
        }
      }
    }
  }
}
</style>

